package com.project.action;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class FileDownloadAction {
	private Integer projectNum;
	private String bathPath;
	private String testURL;
	private String jsonString;// 使用json传递数据
	
	
	public String getTestURL() {
		return testURL;
	}


	public void setTestURL(String testURL) {
		this.testURL = testURL;
	}


	public Integer getProjectNum() {
		return projectNum;
	}


	public void setProjectNum(Integer projectNum) {
		this.projectNum = projectNum;
	}


	public String getBathPath() {
		return bathPath;
	}


	public void setBathPath(String bathPath) {
		this.bathPath = bathPath;
	}


	public String getJsonString() {
		return jsonString;
	}


	public void setJsonString(String jsonString) {
		this.jsonString = jsonString;
	}


	@SuppressWarnings("unchecked")
	public String Filedownload(){
		String parentF = this.bathPath + "\\"+this.projectNum;
		
		parentF = "D:\\JAVA\\tomcat7\\tomcat7\\webapps\\projectMonitor\\uploadFiles";
			
		List<String> sonF = new ArrayList();
		File RF = new File(parentF);
		if(!RF.exists()){
			this.setJsonString("{success:fales,cause:notexisting}");			
		}else{
			String[] sonFN = RF.list();
			for(int i=0;i<sonFN.length;i++){
				sonF.add("http://localhost:8080/projectMonitor/uploadFiles"+"/"+sonFN[i]);
			}
			this.setJsonString("{success:true");
			for(String tmp : sonF){
				this.jsonString+=",";
				this.jsonString+=tmp;
			}
			this.jsonString+="}";
		}
		this.testURL = sonF.get(0);
		return "success";
	}
	
}
